import { createApp } from 'vue'
import App from './App.vue'
import router from "./router/index.ts"
import MetaInfo from 'vue-meta-info'
import ElementPlus from"element-plus"
import axios from 'axios'
import * as ElementPlusIcon from "@element-plus/icons-vue"
import './assets/scss/style.scss'
import './assets/main.css'
import 'element-plus/dist/index.css'
import '@/assets/scss/element-variable.scss'
import 'amfe-flexible'

import locale from 'element-plus/lib/locale/lang/zh-cn' //引入element-plus中文包

import './utils/rem.js';
const debounce = (fn, delay) => {
    let timer = null;
    return function () {
      let context = this;
      let args = arguments;
      clearTimeout(timer);
      timer = setTimeout(function () {
        fn.apply(context, args);
      }, delay);
    }
  }
   
  const _ResizeObserver = window.ResizeObserver;
  window.ResizeObserver = class ResizeObserver extends _ResizeObserver{
    constructor(callback) {
      callback = debounce(callback, 16);
      super(callback);
    }
  }
  const app = createApp(App)
  for(const[key, component] of Object.entries(ElementPlusIcon)){
    app.component(key, component)
  }
  app.config.globalProperties.$axios = axios
  app.use(router).use(MetaInfo).use(ElementPlus).use(locale).mount('#app')
